home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / oop_tp55.zip / LIST5_2.PAS < prev    next >
Pascal/Delphi Source File  |  1990-02-01  |  2KB  |  67 lines

  1. program Listing5_2;
  2.  
  3. type
  4.  
  5. Elf = object
  6.       Name : string;
  7.       constructor Init( Monicker : string );
  8.       procedure ShopScript; { virtual;}
  9.       procedure GoShopping;
  10.       end;
  11.  
  12. VirtualElf = object( Elf )
  13.            procedure ShopScript; { virtual; }
  14.            end;
  15.  
  16. constructor Elf.Init( Monicker : string );
  17. begin
  18.      Name := Monicker;
  19. end;
  20.  
  21. procedure Elf.ShopScript;
  22. begin
  23.      writeln( '<Door slams as ', Name, ' leaves>');
  24.      writeln( '<long pause.......>' );
  25.      writeln( '<Door slams as ', Name, ' returns>');
  26.      writeln( Name, ': I went to the store and bought milk and eggs.');
  27. end;
  28.  
  29. procedure Elf.GoShopping;
  30. begin
  31.      ShopScript;
  32. end;
  33.  
  34. procedure VirtualElf.ShopScript;
  35. var
  36.    ShoppingList : string;
  37. begin
  38.      writeln( Name, ': When I get to the store, I''ll call you.');
  39.      writeln( '<Door slams as ', Name, ' leaves>');
  40.      writeln( '<pause.......>' );
  41.      writeln( 'PHONE: Brrring!');
  42.      writeln( '<pick up phone>' );
  43.      writeln( 'YOU: Hello?' );
  44.      writeln( Name, ': Hi. What do you want me to buy?' );
  45.      write( 'YOU (enter something): ');
  46.      readln( ShoppingList );
  47.      writeln( Name, ': Gotcha. Bye.');
  48.      writeln( '<hang up phone>' );
  49.      writeln( '<pause.......>' );
  50.      writeln( '<Door slams as ', Name, ' returns>');
  51.      writeln( Name, ': As you requested, I bought: ', ShoppingList );
  52. end;
  53.  
  54. var
  55.    Jay : Elf;
  56.    Ray : VirtualElf;
  57.  
  58. begin
  59.      Jay.Init( 'JAY' );
  60.      Ray.Init( 'RAY' );
  61.  
  62.      Jay.GoShopping;
  63.      Ray.GoShopping;
  64. end.
  65.  
  66. { Listing 5-2 }
  67.